//
//  MineAddressView.m
//  WeiYiMei
//
//  Created by iMac on 2019/4/13.
//  Copyright © 2019年 liyefu. All rights reserved.
//

#import "MineAddressView.h"

@interface MineAddressView ()

@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UIImageView *arrow;

@end

@implementation MineAddressView

- (void)setEntity:(AddressEntity *)entity
{
    _entity = entity;
    self.nameLab.text = entity.receContact;
    self.telLab.text = entity.receTel;
    self.addressLab.text = entity.receAddress;
}

- (void)setCanSelect:(BOOL)canSelect
{
    _canSelect = canSelect;
    if (canSelect) {
        self.arrow.hidden = NO;
    }
    else {
        self.arrow.hidden = YES;
    }
}


- (void)setupSubViews
{
    self.backgroundColor = [UIColor whiteColor];
    self.icon = [[UIImageView alloc] init];
    self.icon.image = [UIImage imageNamed:@"pay_address"];
    [self addSubview:self.icon];
    
    self.nameLab = [[UILabel alloc] init];
    self.nameLab.textColor = kColor333333;
    self.nameLab.font = [UIFont systemFontOfSize:16];
    [self addSubview:self.nameLab];
    
    self.telLab = [[UILabel alloc] init];
    self.telLab.textColor = kColor666666;
    self.telLab.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.telLab];
    
    self.addressLab = [[UILabel alloc] init];
    self.addressLab.textColor = kColor333333;
    self.addressLab.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.addressLab];
    
    self.arrow = [[UIImageView alloc] init];
    self.arrow.image = [UIImage imageNamed:@"arrow_right"];
    [self addSubview:self.arrow];
    
    
}

- (void)setupConstraints
{
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(kWidth(15));
    }];
    
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon.mas_right).offset(kWidth(14));
        make.top.equalTo(self).offset(kWidth(20));
    }];
    
    [self.telLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab.mas_right).offset(kWidth(10));
        make.centerY.equalTo(self.nameLab);
        make.right.lessThanOrEqualTo(self).offset(-kWidth(30));
    }];
    
    [self.addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab);
        make.top.equalTo(self.nameLab.mas_bottom).offset(kWidth(15));
        make.bottom.equalTo(self).offset(-kWidth(15));
        make.right.lessThanOrEqualTo(self).offset(-kWidth(30));
    }];
    
    [self.arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(-kWidth(11));
    }];
}

@end
